<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <hello-age @agemsg="handle($event)"></hello-age>
    </div>
    <script>
        Vue.component('hello-age', {
            data: function() {
                return {
                    age: 3
                }
            },
            template: `
            <div>
                <button @click="$emit('agemsg',age)">按钮</button>
            </div>
            `
        })
        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {
                handle: function(e) {
                    console.log(e);
                }
            }
        })
    </script>
</body>

</html>